var app = getApp()


function afterSale(that) {//从后台获取售后订单
  wx.request({
    url: app.globalData.allUrl + "/YMGW/orderFormAction/getOrderFormByStatus",
    data: {
      userid: wx.getStorageSync('userid'),//用户唯一ID
      status: 5 //订单状态ID（1-5）
    },
    method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
    // header: {}, // 设置请求的 header
    success: function (res) {
      // success
      var orderDetail = res.data//得到大订单
      var orderSolved = [];
      var orderSolving = [];
      for (var statu in orderDetail) {
        if (orderDetail[statu].status == 6) {//如果订单状态为6
          orderSolved.unshift(orderDetail[statu])//则添加到待发货订单中
          that.setData({
            orderSolved: orderSolved
          })
        } else if (orderDetail[statu].status == 5) {//如果订单状态为5
          orderSolving.unshift(orderDetail[statu])//则添加到解决中的售后订单中去
          that.setData({
            orderSolving: orderSolving
          })
        }
      }
      app.solvedOrderFormDetail=orderSolved;
      app.solvingOrderFormDetail=orderSolving;
      // console.log(res.data)//从后台根据用户id与订单状态来获取对应的订单数据
      app.complaintOrderFormDetailNumber = 5;
    }
  })
}



module.exports =
  {
    afterSale: afterSale
  };// 这样暴露接口，这里不暴露是不能引用的，